package cn.ztr.familyalbum.web.controller;

import cn.ztr.familyalbum.common.CommonResult;
import cn.ztr.familyalbum.common.ResultCode;
import cn.ztr.familyalbum.entity.TemplateDictionary;
import cn.ztr.familyalbum.service.ITemplateDictionaryService;

import cn.ztr.familyalbum.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/templateDictionary")
public class TemplateDictionaryController {
    @Autowired
    public ITemplateDictionaryService templateDictionaryService;

    /**
    * 模板新增分类
    * @param templateDictionary  传递的实体
    * @return Ajaxresult转换结果
    */
    @RequestMapping(value="/insertDictionary",method= RequestMethod.POST)
    public CommonResult insertDictionary(@RequestBody TemplateDictionary templateDictionary){
        //根据是官方还是客户设置父级ID
        //templateDictionary.setGroupSerialNumber();
         boolean b = templateDictionaryService.insert(templateDictionary);
         if(b){
             return new CommonResult(ResultCode.SUCCESS);
         }
        return new CommonResult(ResultCode.INTERNAL_SERVER_ERROR);
    }


    //获取用户
    @RequestMapping(value = "/{id}",method = RequestMethod.GET)
    public TemplateDictionary get(@PathVariable("id")Long id)
    {
        return templateDictionaryService.selectById(id);
    }




}
